#ifdef HAVE_CONFIG_H
#        include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "support.h"
#include "clist.h"
#include "mainwindow.h"
#include "newinfo.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
        g_object_set_data_full (G_OBJECT (component), name, \
                gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
        g_object_set_data (G_OBJECT (component), name, widget)
        
GtkWidget* create_clist_group(GtkWidget *window_main,
						GtkWidget *hbox_main)
{
	GtkWidget *clist_group;
        GtkWidget *scrolledwindow_group;
        GtkWidget *label_group_class;/*label '分组'*/
        GtkWidget *label_group_nums;/*label '数量'*/
	
	scrolledwindow_group = gtk_scrolled_window_new (NULL, NULL);
        gtk_widget_show (scrolledwindow_group);
        gtk_box_pack_start (GTK_BOX (hbox_main), scrolledwindow_group, FALSE, TRUE, 0);
        gtk_widget_set_size_request (scrolledwindow_group, 180, -1);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_group), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow_group), GTK_SHADOW_IN);

        clist_group = gtk_clist_new (2);
        gtk_widget_show (clist_group);
        gtk_container_add (GTK_CONTAINER (scrolledwindow_group), clist_group);
        gtk_clist_set_column_width (GTK_CLIST (clist_group), 0, 82);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_group),0,TRUE);
        gtk_clist_set_column_width (GTK_CLIST (clist_group), 1, 70);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_group),1,TRUE);
        gtk_clist_column_titles_show (GTK_CLIST (clist_group));

        label_group_class = gtk_label_new (_("\345\210\206\347\273\204"));
        gtk_widget_show (label_group_class);
        gtk_clist_set_column_widget (GTK_CLIST (clist_group), 0, label_group_class);

        label_group_nums = gtk_label_new (_("\346\225\260\351\207\217"));
        gtk_widget_show (label_group_nums);
        gtk_clist_set_column_widget (GTK_CLIST (clist_group), 1, label_group_nums);
        
        g_signal_connect ((gpointer) clist_group, "button_press_event",
                    				G_CALLBACK (on_clist_group_button_press_event),
                    				NULL);     
        g_signal_connect((gpointer)(clist_group),"select_row",
        					G_CALLBACK(clist_group_get_selection_row),
        					(gpointer)&newinfo);
         /* Store pointers to all widgets, for use by lookup_widget(). */
        GLADE_HOOKUP_OBJECT (window_main, scrolledwindow_group, "scrolledwindow_group");
        GLADE_HOOKUP_OBJECT (window_main, clist_group, "clist_group");
        GLADE_HOOKUP_OBJECT (window_main, label_group_class, "label_group_class");
        GLADE_HOOKUP_OBJECT (window_main, label_group_nums, "label_group_nums");
        
        return clist_group;
}
       
GtkWidget* create_clist_show(GtkWidget *window_main,GtkWidget *hbox_main)
{        
        GtkWidget *clist_show;
        GtkWidget *scrolledwindow_clist;
        GtkWidget *label_show_name;/*label '姓名'*/
        GtkWidget *label_show_class;/*label '班级'*/
        GtkWidget *label_show_tel;/*label '电话'*/
        GtkWidget *label_show_mail;/*label '邮箱'*/
        GtkWidget *label_show_blog;/*label '博客'*/
	
	

        scrolledwindow_clist = gtk_scrolled_window_new (NULL, NULL);
        gtk_widget_show (scrolledwindow_clist);
        gtk_box_pack_start (GTK_BOX (hbox_main), scrolledwindow_clist, TRUE, TRUE, 0);
        gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow_clist), 2);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_clist), 
        					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow_clist), 
        												GTK_SHADOW_IN);

        clist_show = gtk_clist_new (5);
        gtk_widget_show (clist_show);
        gtk_container_add (GTK_CONTAINER (scrolledwindow_clist), clist_show);
        gtk_widget_set_size_request (clist_show, 426, -1);
        gtk_clist_set_column_width (GTK_CLIST (clist_show), 0, 60);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_show),0,TRUE);
        gtk_clist_set_column_width (GTK_CLIST (clist_show), 1, 80);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_show),1,TRUE);
        gtk_clist_set_column_width (GTK_CLIST (clist_show), 2, 100);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_show),2,TRUE);
        gtk_clist_set_column_width (GTK_CLIST (clist_show), 3, 200);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_show),3,TRUE);
        gtk_clist_set_column_width (GTK_CLIST (clist_show), 4, 250);
        gtk_clist_set_column_auto_resize(GTK_CLIST(clist_show),4,TRUE);
        gtk_clist_column_titles_show (GTK_CLIST (clist_show));

        label_show_name = gtk_label_new (_("\345\247\223\345\220\215"));
        gtk_widget_show (label_show_name);
        gtk_clist_set_column_widget (GTK_CLIST (clist_show), 0, label_show_name);   
        label_show_class = gtk_label_new (_("\347\217\255\347\272\247"));
        gtk_widget_show (label_show_class);
        gtk_clist_set_column_widget (GTK_CLIST (clist_show), 1, label_show_class);

        label_show_tel = gtk_label_new (_("\347\224\265\350\257\235"));
        gtk_widget_show (label_show_tel);
        gtk_clist_set_column_widget (GTK_CLIST (clist_show), 2, label_show_tel);
        
	label_show_mail = gtk_label_new (_("\351\202\256\347\256\261"));
        gtk_widget_show (label_show_mail);
        gtk_clist_set_column_widget (GTK_CLIST (clist_show), 3, label_show_mail);
        
        label_show_blog = gtk_label_new (_("\345\215\232\345\256\242"));
        gtk_widget_show (label_show_blog);
        gtk_clist_set_column_widget (GTK_CLIST (clist_show), 4, label_show_blog);

         g_signal_connect ((gpointer) clist_show, "button_press_event",
                    					G_CALLBACK (on_clist_show_button_press_event),
                    					NULL);         							                                                                   
	g_signal_connect ((gpointer) clist_show, "select_row",
                    					G_CALLBACK (clist_show_get_selection_row),
                    					(gpointer)&clist);         	
        GLADE_HOOKUP_OBJECT (window_main, scrolledwindow_clist, "scrolledwindow_clist");
        GLADE_HOOKUP_OBJECT (window_main, clist_show, "clist_show");
        GLADE_HOOKUP_OBJECT (window_main, label_show_name, "label_show_name");
        GLADE_HOOKUP_OBJECT (window_main, label_show_class, "label_show_class");
        GLADE_HOOKUP_OBJECT (window_main, label_show_tel, "label_show_tel");
        
        return clist_show;

}
